import { resources, SpriteFrame } from 'cc'
import Singleton from '../Base/Singleton'
import { ITile } from '../Levels'

/*
* 资源加载
*/
export default class ResourceManager extends Singleton{
  // override
  static get Instance() {
    return super.GetInstance<ResourceManager>()
  }
  // 加载资源
  loadDir(path:string, type:typeof SpriteFrame = SpriteFrame) {
    return new Promise<SpriteFrame[]>((resolve, reject) => {
      resources.loadDir(path, type, function (err, assets) {
        if(err) {
          reject(err)
          return
        }

        resolve(assets)
      })
    })
  }
}
